﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Erebos.GameScreenFiles.WorldObjects
{
    class TreeObject : Object
    {
        private Vector3 _position;
        private Model _model;

        public TreeObject(Vector3 position, string code)
        {
            _position = position;
            _model = MainGame.LoadContent<Model>("objects/tree" + code);
        }

        public override void Draw(GameTime gameTime)
        {
            _model.Draw(Matrix.CreateRotationX(MathHelper.Pi) * Matrix.CreateTranslation(new Vector3(_position.X, _position.Y, -_position.Z)), Camera.ViewMatrix, Camera.ProjectionMatrix);

            /*foreach (ModelMesh mesh in _model.Meshes)
            {
                for (int i = 0; i < mesh.Effects.Count; i++)
                {
                    Effect currentEffect = mesh.Effects[i];
                    Matrix worldMatrix = modelTransforms[mesh.ParentBone.Index] * Matrix.CreateTranslation(_position);
                    mesh.Effects[i].CurrentTechnique = mesh.Effects[i].Techniques[0];
                    mesh.Effects[i].Parameters["World"].SetValue(worldMatrix);
                    mesh.Effects[i].Parameters["View"].SetValue(Camera.ViewMatrix);
                    mesh.Effects[i].Parameters["Projection"].SetValue(Camera.ProjectionMatrix);
                    mesh.Effects[i].Parameters["Ambient"].SetValue(1.0f);
                    mesh.Effects[i].Parameters["xEnableLighting"].SetValue(true);
                }
                mesh.Draw();
            }*/
            base.Draw(gameTime);
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }
    }
}
